package com.shuoyue.ycgk.ui.recruitment;

import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.entity.RecruitmentMainInfo;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;

import io.reactivex.Observable;


public interface NoticeMainContract {
    interface View extends BaseView {
        void setNoticeMainInfo(RecruitmentMainInfo info);
    }

    class Presenter extends BasePresenter<View> {
        Model model = new Model();

        public void getNoticeMain(Integer modelId) {
            apply(model.getNoticeMain(modelId))
                    .subscribe(new ApiSubscriber<Optional<RecruitmentMainInfo>>(mView, this) {
                        @Override
                        public void onNext(Optional<RecruitmentMainInfo> recruitmentMainInfoOptional) {
                            super.onNext(recruitmentMainInfoOptional);
                            mView.setNoticeMainInfo(recruitmentMainInfoOptional.getIncludeNull());
                        }
                    });
        }
    }

    class Model {
        public Observable<BaseResult<RecruitmentMainInfo>> getNoticeMain(Integer modelId) {
            return RetrofitClient.getInstance().getApi().getNoticeMain(1, null);
        }
    }
}
